<script lang="ts" setup>
import { useStatisticalStore } from '@/store/modules/dcp/message_management/statistical';

const sum = ref<number>(0);
const successMsg = ref<number>(0);
const errorMsg = ref<number>(0);
onMounted(async () => {
  await useStatisticalStore().getAllMsg();
  useStatisticalStore().getSumMsg();
  sum.value = useStatisticalStore().sum;
  successMsg.value = useStatisticalStore().successMsg;
  errorMsg.value = useStatisticalStore().errorMsg;
});
</script>

<template>
  <div>
    <div class="header">
      <div class="left">
        <a-space>
          <div class="pjTitle">
            短信发送情况
          </div>
        </a-space>
      </div>
      <div class="right" />
    </div>
    <div class="content">
      <a-row type="flex" justify="space-around">
        <a-col :span="6">
          <a-statistic :value="sum" style="margin-right: 50px; border-right: 1px solid #ebeef5;">
            <template #title>
              <FileTextOutlined style="color: #2974ff;" />
              发送总数
            </template>
          </a-statistic>
        </a-col>
        <a-col :span="6">
          <a-statistic :value="successMsg" style="margin-right: 50px; border-right: 1px solid #ebeef5;">
            <template #title>
              <FileDoneOutlined style="color: #87c78d;" />
              发送成功数
            </template>
          </a-statistic>
        </a-col>
        <a-col :span="6">
          <a-statistic :value="errorMsg" style="margin-right: 50px; border-right: 1px solid #ebeef5;">
            <template #title>
              <FileExcelOutlined style="color: #ff8819;" />
              发送失败数
            </template>
          </a-statistic>
        </a-col>
        <a-col :span="6">
          <a-statistic :precision="2" suffix="%" :value="successMsg / sum * 100 || 0">
            <template #title>
              <FileSyncOutlined style="color: #58b0fe;" />
              发送成功率
            </template>
          </a-statistic>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<style lang="scss">
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 31px;
  margin-bottom: 10px;

  .pjTitle {
    padding-left: 15px;
    background: url("@/assets/images/title-left-bg.svg") no-repeat;
  }

  .right {
    display: flex;
    align-items: center;
  }
}

.content {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  height: 95%;
  overflow: auto;
  overflow-y: auto;
  text-align: center;

  .d-table {
    flex-grow: 1;
    height: 100%;
    max-height: 100%;
    padding: 10px;
  }
}
</style>
